package com.xbongbong.parent.interfaces;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import org.elasticsearch.index.query.BoolQueryBuilder;

import java.util.List;

/**
 * @author 吴峰
 * @date 2022/02/08 17:02
 */
public interface BusinessPermissionService<D, F> {

    List<Integer> businessType();

    /**
     * com.xbongbong.saas.help.SaasDetailPermissionHelp#checkDelPermission(java.util.List, com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt, java.lang.Integer)
     * 判断编辑权限
     *
     * @param userIdIn 下属员工（包含本人）
     * @param paasFormDataEntityExt 表单数据信息
     * @param businessType 业务类型
     * @return boolean true为有权限，false为无权限
     * @throws XbbException 异常
     * @author long.rao
     * @date 2019-11-22 15:26
     */
    boolean checkDelPermission(List<String> userIdIn, D paasFormDataEntityExt, Integer businessType) throws XbbException;
    /**
     * 有团队的详情权限校验
     * com.xbongbong.saas.help.SaasDetailPermissionHelp#checkPermissionByTeam(java.lang.Integer, org.elasticsearch.index.query.BoolQueryBuilder)
     * @param businessType
     * @param boolQueryBuilder
     * @return
     * @throws XbbException
     */
    Boolean checkPermissionByTeam(String corpid, Integer businessType, BoolQueryBuilder boolQueryBuilder) throws XbbException;

    /**
     * 校验数据编辑权限(团队权限&共享权限)
     *
     * @param formEntity
     * @param paasFormDataEntityExt
     * @param loginUser
     * @param subBusinessType
     * @throws XbbException
     */
    void checkDataEditPermission(F formEntity, D paasFormDataEntityExt, UserVO loginUser, Integer subBusinessType) throws XbbException;

    /**
     * 团队权限及共享权限校验
     *  com.xbongbong.saas.help.SaasDetailPermissionHelp.checkPermission
     * @param formEntity
     * @param paasFormDataEntityExt
     * @param loginUser
     * @param subBusinessType
     * @throws XbbException
     */
    void checkPermission(F formEntity, D paasFormDataEntityExt, UserVO loginUser, Integer subBusinessType) throws XbbException;


    /**
     *  com.xbongbong.saas.help.SaasDetailPermissionHelp.checkPermission
     * @param formEntity
     * @param paasFormDataEntityExt
     * @param loginUser
     * @param subBusinessType
     * @throws XbbException
     */
    boolean hasPermission(F formEntity, D paasFormDataEntityExt, UserVO loginUser, Integer subBusinessType) throws XbbException;

}
